﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web.Routing;

namespace Deixei.Web
{
    public static class Helpers
    {
        public static DeixeiWebContext DeixeiWebContext(this ViewContext viewContext)
        {
            return viewContext.RequestContext.DeixeiWebContext();
        }

        public static DeixeiWebContext DeixeiWebContext(this RequestContext requestContext)
        {
            DeixeiWebContext context = requestContext.HttpContext.Items["DeixeiWebContext"] as DeixeiWebContext;
            if (context == null)
            {
                context = new DeixeiWebContext(requestContext);
                requestContext.HttpContext.Items["DeixeiWebContext"] = context;
            }
            return context;
        }

    }
}
